home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 15673 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  993 b 

  1. Path: news.ccs.queensu.ca!qlink!3mb42
  2. From: 3mb42@qlink.queensu.ca (Ben David Moran)
  3. Newsgroups: comp.lang.c++
  4. Subject: Using the %c control in SCANF
  5. Date: 7 Apr 1996 22:35:58 GMT
  6. Organization: Queen's University, Kingston
  7. Message-ID: <4k9g0e$eom@knot.queensu.ca>
  8. NNTP-Posting-Host: qlink.queensu.ca
  9. X-Newsreader: TIN [version 1.2 PL2]
  10.  
  11. Can anyone please give me some examples of using the %c control in the 
  12. scanf function.
  13.  
  14. I keep getting segmentation faults when I use %c in the following line:
  15.  
  16.     scanf ("%s%c", textLine);
  17.  
  18. the variable "textLine" is declared as
  19.  
  20.     char textLine[MAXBUFFERSIZE];
  21.  
  22. while MAXBUFFERSIZE is an integer constant that equals 256.
  23.  
  24. I am attempting to receive input, but not only up to the next non-blank 
  25. character.  I want all of what is typed until the return key is hit.
  26.  
  27. Can anyone help me use the %c control properly? If not, do you know of a 
  28. better way of accomplishing this, perhaps with iostream.h functions instead?
  29.  
  30. Any help is appreciated, thanks. 
  31.  
  32. M
  33.  
  34.